package crond

import (
	"sale-admin/config/mysql"
	"sale-admin/internal/models"

	"github.com/golang-module/carbon"
)

func RedemptionCodeCheck() error {
	db := mysql.NewDB()
	db.Model(&models.MaRedemptionCode{}).
		Where("expiration_time < ?", carbon.Now().ToDateTimeString()).
		Where("redemption_state = 1").
		UpdateColumn("redemption_state", 0)
	return nil
}
